{% extends 'base_login.html' %}
{% block content %}
    <div class="form-group">
        <input id="user_name" type="text" class="form-control" placeholder="用户名" required="">
    </div>
    <div class="form-group">
        <input id="user_pwd" type="password" class="form-control" placeholder="密码" required="">
    </div>
    <button type="button" onclick="login()" class="btn btn-primary block full-width m-b">登 录</button>
    <script>
        $(function () {
            document.onkeydown = function (e) {
                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    login()
                }
            }
        });
        function login() {
            $.ajax({
                url: "/user/login",
                type: "post",
                data: {
                    user_name: $('#user_name').val(),
                    user_pwd: $('#user_pwd').val()
                },
                success: function (data) {
                    if (data.status == "ok") {
                        window.location.href = "/"
                    } else {
                        alert(data.message)
                    }
                }
            })
        }
    </script>
{% endblock %}